package org.datacoder.geocoding.datastructures.util

import org.datacoder.geocoding.datastructures.geoshapes.*

class GeoPointComparator implements Comparator<GeoPoint> {

    int type

    public GeoPointComparator(int type){
        this.type = type
    }

    public int compare(GeoPoint gp1, GeoPoint gp2){
        double returnVal
        returnVal = gp1.retrieveValue(type) - gp2.retrieveValue(type)
        if(returnVal == 0){
            returnVal = gp1.juris.id - gp2.juris.id
        }
        if(returnVal == 0){
            return 0
        }
        return ((returnVal > 0) ? 1 : -1)
    }

}
